﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="admin_add.aspx.cs" Inherits="Web_Admin_Admin_admin_add" %>

<%@ Register src="../ascx/navigation.ascx" tagname="navigation" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理员添加</title>
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../css/default.css" />
    <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js"></script>
    <script type="text/javascript">
        var id = <%=id %>;
        var reg = /[a-zA-Z0-9]{0,}/;
        //方法
        $.validator.addMethod(
            "username_validate",
            function(value, element) {
                return reg.test($.trim(value));
            },
            "用户名必须为A-Z0-9的字符"
        ); 
        $.validator.addMethod(
            "pwd_validate",
            function(value, element) {
                if(id<1)
                {
                    if($.trim(value)=="")
                    {
                        return false;
                    }
                }
                return true;
            },
            "密码不能为空"
        );   
        $.validator.addMethod(
            "pwd_empty_validate",
            function(value, element) {
                if($.trim(value)!="")
                {
                    return reg.test($.trim(value));
                }
                else
                {
                    return true;
                }
            },
            "密码必须为A-Z0-9的字符"
        );
        $.validator.addMethod(
            "pwd1_validate",
            function(value, element) {
                if(id<1)
                {     
                    if($.trim(value)=="")
                    {
                        return false;
                    }
                }
                
                return true;
            },
            "确认密码不能为空"
        );
        $.validator.addMethod(
            "pwd1_empty_validate",
            function(value, element) {
                if($.trim(value)!="")
                {
                    return reg.test($.trim(value));
                }
                else
                {
                    return true;
                }
            },
            "确认密码必须为A-Z0-9的字符"
        );
        $.validator.addMethod(
            "pwd1_no_validate",
            function(value, element) {
                if(id<1)
                {
                    if($.trim(value)!=$.trim($("#txt_Password").val()))
                    {
                        return false;
                    }
                }
                return true;
            },
            "密码与确认密码不一致"
        );
        
        //验证
        $().ready(function() {
            $("#form1").validate({
                rules: {
                    drpClass: { required: true },
                    txt_UserName: { required: true,username_validate:true },
                    txt_Password: { pwd_validate:true,pwd_empty_validate:true },
                    txt_ComPassword: { pwd1_validate:true,pwd1_empty_validate:true,pwd1_no_validate:true },
                    txt_Email: { email: true }
                },
                messages: {
                    drpClass: { required: "请选择角色类型" },
                    txt_UserName: { required: "用户名不能为空" },
                    txt_Email: { email:"邮箱格式不正确" }
                },
                errorElement: "em",
                errorPlacement: function(error, element) {
                    error.appendTo(element.parent());
                }
            });
        });
    </script>
</head>
<body>
<form id="form1" runat="server">
<uc1:navigation ID="navigation1" Title="管理员添加" runat="server" />
<div class="adRbox">
    <div class="arTabBox arFmtd">
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <th class="fmth"><asp:Literal ID="lit_title" Text="管理员添加" runat="server"></asp:Literal></th>
            <th>&nbsp;</th>
          </tr>
          <tr>
            <td class="addtd">角色类型：</td>
            <td>
                <asp:DropDownList ID="drpClass" DataTextField="RoleName" DataValueField="ID" AppendDataBoundItems="true" runat="server">
                    <asp:ListItem Text="--请选择--" Value=""></asp:ListItem>
                </asp:DropDownList>&nbsp;<em>*</em>&nbsp;
            </td>
          </tr>
          <tr>
            <td class="addtd">用户名：</td>
            <td><asp:TextBox ID="txt_UserName" CssClass="ipt1" runat="server"></asp:TextBox>&nbsp;<em>*</em>&nbsp;</td>
          </tr>
          <tr>
            <td class="addtd">密码：</td>
            <td><asp:TextBox ID="txt_Password" TextMode="Password" CssClass="ipt1" runat="server"></asp:TextBox><asp:Literal ID="lit_password" runat="server"></asp:Literal></td>
          </tr>
          <tr>
            <td class="addtd">确认密码 ：</td>
            <td><asp:TextBox ID="txt_ComPassword" TextMode="Password" CssClass="ipt1" runat="server"></asp:TextBox><asp:Literal ID="lit_compassword" runat="server"></asp:Literal></td>
          </tr>
          <tr>
            <td class="addtd">姓名 ：</td>
            <td><asp:TextBox ID="txt_Name" CssClass="ipt1" runat="server"></asp:TextBox></td>
          </tr>
          <tr>
            <td class="addtd">邮箱：</td>
            <td><asp:TextBox ID="txt_Email" CssClass="ipt1" runat="server"></asp:TextBox>&nbsp;&nbsp;</td>
          </tr>
          <tr>
            <td class="addtd">状态：</td>
            <td><asp:CheckBox ID="chk_IsPass" Text="审核" runat="server" /></td>
          </tr>
          <tr>
            <td class="addtd">&nbsp;<asp:HiddenField ID="hid_password" runat="server" /></td>
            <td class="fmBtns"><label>
                <asp:Button ID="but_save" runat="server" Text="保存" onclick="but_save_Click" />
                <input type="button" name="button3" id="button3" value="返回" onclick="history.back();" />
            </label></td>
          </tr>
        </table>
    </div>
</div>
</form>
</body>
</html>
